//
//  BApplyForMoneyReasonCell.m
//  DistributorAB
//
//  Created by LZY on 2019/10/8.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "BApplyForMoneyReasonCell.h"

@interface BApplyForMoneyReasonCell () <UITextViewDelegate>
@property (nonatomic, strong) UITextView *tvReason;//损坏描述
@end

@implementation BApplyForMoneyReasonCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupViewAction];
    }
    return self;
}
#pragma mark - 界面布局
- (void)setupViewAction{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIView *viewLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 2)];
    viewLine.backgroundColor = kColorWithHex(0xf2f2f2);
    [self.contentView addSubview:viewLine];
    
    UILabel *lblNotice = [[UILabel alloc] initWithFrame:CGRectMake(25, 22, 70, 20)];
    lblNotice.text = @"损坏描述:";
    lblNotice.font = [UIFont systemFontOfSize:14];
    lblNotice.textColor = kColorWithHex(0x666666);
    [self.contentView addSubview:lblNotice];
    
    _tvReason = [[UITextView alloc] initWithFrame:CGRectMake(95, 18, kScreen_Width - 105, 91)];
    _tvReason.placeholder = @"请填写损坏描述";
    _tvReason.font = [UIFont systemFontOfSize:14];
    _tvReason.textColor = kColorWithHex(0x333333);
    _tvReason.layer.cornerRadius = 8;
    _tvReason.layer.masksToBounds = YES;
    _tvReason.layer.borderColor = kColorWithHex(0xdbdbdb).CGColor;
    _tvReason.layer.borderWidth = 1;
    _tvReason.delegate = self;
    [self.contentView addSubview:_tvReason];
}
#pragma mark - UITextViewDelegate
- (void)textViewDidChange:(UITextView *)textView{
    //去掉首尾的空格
    self.applyReason = [textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}

- (void)setIsGrantDetail:(BOOL)isGrantDetail{
    _isGrantDetail = isGrantDetail;
    if (_isGrantDetail) {
        //_tvReason.userInteractionEnabled = NO;
        _tvReason.editable = NO;
    }
}
- (void)setGrantDetailModel:(ZGrantDetailModel *)grantDetailModel{
    if (grantDetailModel) {
        _grantDetailModel = grantDetailModel;
        _tvReason.text = grantDetailModel.reason;
    }
}
+ (CGFloat)cellHeight{
    return 146.0;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
